package useful;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cuiH
 * Date: 13-10-17
 */
public class DateExample {
    public static void main(String[] args) throws ParseException {
        /*
        * java.util.date to java.sql.date
        * */
        java.util.Date utilDate = new Date();
        System.out.println("utilDate:"+utilDate);
        java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
        System.out.println("sqlDate:"+sqlDate);

        /*
        * String to Date
        * */
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy" );
        Date date = format.parse("2013.10.15");
        System.out.println("formatDate:"+date);
        System.out.println("string:" + date.toString());
      }
}
